// @ts-ignore
// http://unclechen.github.io/2018/06/09/%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E7%BD%91%E9%A1%B5%E5%92%8CChrome%E6%8F%92%E4%BB%B6%E4%B9%8B%E9%97%B4%E7%9A%84%E9%80%9A%E4%BF%A1/
import browser from "webextension-polyfill";
// TODO RollupError: Could not resolve "../../assets/layouts/logo.png" from "WebExtension/src/content.ts"
// @ts-ignore
import iconUrl from "../../assets/layouts/logo.png";
import {Events, showNotifyEventType, webExtDomId} from "./common/Utils";

const installNode = document.createElement('div');
installNode.id = webExtDomId;
installNode.style.display = 'none';
installNode.setAttribute('version', browser.extension.getManifest().version); // 把版本号放到属性里
document.body.appendChild(installNode);


installNode.addEventListener(Events.showNotify, function (ev: CustomEvent<showNotifyEventType>) {
  const data = ev.detail
  browser.notifications.create({
    title: data.title,
    type: 'basic',
    message: data.options.body,
    iconUrl: iconUrl
  })
});
